<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title> 
</head>   
<body> 
    <button>弹出</button> 
    <div class="box2">  
        <div class="box3">
              <p> <span class="cha">X</span>   </p>
        </div>  
    </div> 

</body>
<script>
var button=document.querySelector("button")
var box2=document.querySelector(".box2")
var box3=document.querySelector(".box3")
var cha=document.querySelector(".cha")
button.onclick=function(){
     box2.style.display="block"
     box3.style.display="block"
}
cha.onclick=function(){
     box2.style.display="none"
     box3.style.display="none"
}

</script>
</html>
<style>
button{
    margin-left: 50%;
    /* z-index: -1; */
   
}
.box2{
    width: 100%;
    height: 705px;
    background-color:rgba(0, 0, 0,0.5);
    position: absolute;
    top: 0px;
    left: 0px;
    z-index:10001;
   display: none;
}
.box3{
    width: 500px;
    height: 300px;
    background-color: white;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    border: 5px solid orange;
    display: none;
}
p{
    width: 100%;
    height: 40px;
    background-color: darkorange;
    margin-top: 0;
}
span{
   color: orange;
   background-color: white;
   float: right;
   display: block;
   width: 30px;
   height: 30px;
   text-align: center;
   line-height: 30px;
   margin-top: 5px;
   margin-right: 5px;
}
</style>